package student_system.dep_Controller;

import student_system.bean.dep;
import student_system.Dao.depdao;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/depdelete")
public class dep_delete extends HttpServlet {
    depdao dao=new depdao();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doPost(req, resp);
//        String snoStr=req.getParameter("dno");
//        int sno=0;
//        try {
//            sno = Integer.parseInt(snoStr);
//        } catch (Exception e) {
//            System.out.println("error");
//            //return null;
//        }


        String dno=req.getParameter("dno");
        dao.depdelete(dno);
        List<dep> list=dao.dep_select();
        req.setAttribute("deplists",list);
        RequestDispatcher dispatcher =req.getRequestDispatcher("depselect_1.jsp");
        dispatcher.forward(req,resp);

    }
}
